package com.zzcoder.mall.common.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public final class JsonUtil {
    private static ObjectMapper mapper = new ObjectMapper();

    public static String toJSON(Object obj) throws JsonProcessingException {
        return mapper.writeValueAsString(obj);
    }

    public static Object fromJSON(String json, Class c) throws JsonProcessingException {
        return mapper.readValue(json, c);
    }
}
